package com.financial.management.contextual.focus;

import java.util.List;

import org.cemantika.contextconsumer.ContextConsumerAdapter;
import org.cemantika.metamodel.structure.Agent;
import org.cemantika.metamodel.structure.Focus;
import org.cemantika.metamodel.structure.RelevanceAssociation;
import org.cemantika.metamodel.structure.RelevanceType;

import com.financial.management.entities.Categoria;
import com.financial.management.entities.Conta;
import com.financial.management.entities.Lancamento;
import com.financial.management.entities.User;

@Focus(isActivated = true)
public class LancamentoCreate implements ContextConsumerAdapter {
    
	@Agent
	private User user;
	
	private Lancamento lancamento;
	
	
	public LancamentoCreate(Lancamento lancamento) {
		this.lancamento = lancamento;
	}

	@RelevanceAssociation(element = "Lancamento.valor", weight = RelevanceType.HIGH)
	public Double getLancamentoValor() {
		return lancamento.getValor();
	}
	
	@RelevanceAssociation(element = "Lancamento.categoria", weight = RelevanceType.HIGH)
	public Categoria getLancamentoCategoria() {
		return lancamento.getCategoria();
	}
	
	@RelevanceAssociation(element = "Lancamento.conta", weight = RelevanceType.HIGH)
	public Conta getLancamentoConta() {
		return lancamento.getConta();
	}
	
	
	@Override
	public List<Object> getContextualEntities() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void updateContextualEntity(Object obj) {
		// TODO Auto-generated method stub
		
	}

	public Lancamento getLancamento() {
		return lancamento;
	}

	public void setLancamento(Lancamento lancamento) {
		this.lancamento = lancamento;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((lancamento == null) ? 0 : lancamento.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LancamentoCreate other = (LancamentoCreate) obj;
		if (lancamento == null) {
			if (other.lancamento != null)
				return false;
		} else if (!lancamento.equals(other.lancamento))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}
	
	
	

}
